﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class WorkTime_SV_EmpCardId : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent();

            Master.DataSource = WMaster;

            MasterPage_MasterPage mpg = (MasterPage_MasterPage)this.Page.Master;
            mpg.HelpHref = "~/Help/WorkTime/工号与门禁卡号对应表.htm";
            mpg.PageName = "工号与门禁卡号对应表";
            mpg.PicUrl = "";
            mpg.IntiBar();
        }
    }

    private void InitializeComponent()
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WorkTime_SV_EmpCardId));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = true;
        this.WMaster.AlwaysClose = false;
        this.WMaster.DeleteIncomplete = true;
        this.WMaster.Guid = null;
        this.WMaster.LastKeyValues = null;
        this.WMaster.Locale = new System.Globalization.CultureInfo("zh-CN");
        this.WMaster.PacketRecords = 200;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "SWorkTime.WorkTime_SV_EmpCardId";
        this.WMaster.ServerModify = true;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();

    }

    protected void Refresh_Click(object sender, EventArgs e)
    {
        string dpt = DepartmentDList1.SelectDepmanetId;
        string uname = SelUser.EmpName;
        string cardid = txtCardId.Text.Trim();

        dpt = (dpt == "0" || dpt == "" ? "" : " and Employees.DepartmentId like '" + dpt + "%'");
        uname = " and Employees.EmpName like '%" + uname.Trim() + "%'";
        cardid = cardid != "" ? "and WorkTime_SV_EmpCardId.CardId=" + cardid : "";

        InitializeComponent();
        WMaster.SetWhere(" 1=1 " + dpt + uname + cardid);
        Master.DataSource = WMaster;


    }
    protected void Master_ApplyError(object sender, Srvtools.ApplyErrorEventArgs e)
    {
        if (e.Exception.Message.IndexOf("门禁卡号已存在") != -1)
        {
            ClientScript.RegisterStartupScript(GetType(), "", "alert('门禁卡号已存在')", true);
            e.Cancel = true;
        }
    }
}
